<template>
    <div>
        <div style="margin-top: 10%;margin-right: 30%;margin-left: 30%;width:300px">
            <el-form ref="form" :model="form" label-width="120px">
                <el-form-item label="发货单号：">
                    <el-input v-model="form.order"></el-input>
                </el-form-item>
                <el-form-item label="发货地址：">
                    <el-input v-model="form.send_address"></el-input>
                </el-form-item>
                 <el-form-item label="收货地址：">
                    <el-input v-model="form.delivery_address"></el-input>
                </el-form-item>
                <el-form-item label="货物类型：">
                    <el-select v-model="form.value1" style="width: 180px;">
                      <el-option v-for="item in options1" :key="item.id" :value="item.id" :label="item.goods_name"></el-option>
                    </el-select>
                </el-form-item>
                 <el-form-item label="客户信息：">
                    <el-select v-model="form.value2" style="width: 180px;">
                      <el-option v-for="item in options2" :key="item.id" :value="item.id" :label="item.clint_name"></el-option>
                    </el-select>
                </el-form-item>  
                 <el-form-item>
                    <el-button type="primary" @click="onSubmit">立即添加</el-button>
                </el-form-item>
                </el-form>
        </div>
    </div>
</template>

<script>
import {send,getgoods,getclient} from '../../api/api.js'
export default {
    data() {
      return {
        form: {
            value1: '',
            value2:'',
            order: '',
            send_address: '',
            delivery_address: '',    
        },
        options1: [],
        options2: [],
      }
    },
    mounted:function(){
        this.get_goods()
        this.all_client()
    },
    methods: {
         //获取所有客户信息
        all_client() {
            var params = {
        };
        getclient(params).then(res=>{
            console.log(res.data)
            this.options2 = res.data
        })
        },
        //获取货物
        get_goods(){
            var params = {
            };
            getgoods(params).then(res=>{
            console.log(res)
                this.options1=res
            })
        },
        onSubmit() {
        console.log(this.form.value1,this.form.order,this.form.send_address,this.form.delivery_address,this.form.value2);
        var params = {
                client_id : this.form.value2,
                good_id : this.form.value1,
                order : this.form.order,
                send_address : this.form.send_address,
                delivery_address : this.form.delivery_address,
            };
            send(params).then(res=>{
              this.$message(res.message)
          })
      }
    }
}
</script>

<style>

</style>